package cn.bdqn.controller;

import cn.bdqn.domain.Cargo;
import cn.bdqn.service.CargoService;
import cn.bdqn.utils.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author dkj
 */
@RestController
public class CargoController {


    @Autowired
    private CargoService cargoService;

    /**
     * 根据主键id查询
     * @param id
     * @return
     */
    @GetMapping(value = "/cargo/queryByPrimaryKey/{id}")
    public Result queryByPrimaryKey(@PathVariable("id") Integer id){
        return cargoService.queryByPrimaryKey(id);
    }

    /**
     * 多条件查询   分页
     * @param cargo
     * @return
     */
    @GetMapping(value = "/cargo/queryByCargo/cargo/pageNum/{pageNum}/pageAmount/{pageAmount}")
    public Result queryByCargo(Cargo cargo, @PathVariable("pageNum") Integer pageNum, @PathVariable("pageAmount") Integer pageAmount){
        return cargoService.queryByCargo(cargo, pageNum, pageAmount);
    }

    /**
     * 新增
     * @param cargo
     */
    @RequestMapping(value = "/cargo/insert/cargo")
    public Result insert(Cargo cargo){
        return cargoService.insert(cargo);
    }

    /**
     * 选择更新
     * @param cargo
     */
    @RequestMapping(value = "/cargo/updateByPrimaryKeySelective/cargo")
    public Result updateByPrimaryKeySelective(Cargo cargo){

        return cargoService.updateByPrimaryKeySelective(cargo);
    }
}
